#include "TutorialState.h"
#include "../DeadlyShadowsLastHope/Game.h"
#include "MainMenuState.h"

CTutorialState* CTutorialState::GetInstance(void)
{
	static CTutorialState s_Instance;
	return &s_Instance;
}

CTutorialState::CTutorialState(void)
{
	m_nHowToPlay			= -1;
}

CTutorialState::~CTutorialState(void) { }

void CTutorialState::Enter(void)
{
	//setup the state
	m_pD3D	= CSGD_Direct3D::GetInstance();
	m_pTM	= CSGD_TextureManager::GetInstance();
	m_pDI	= CSGD_DirectInput::GetInstance();
	m_pXA	= CSGD_XAudio2::GetInstance();
	m_pTM	= CSGD_TextureManager::GetInstance();

	m_pFont.Load("../resources/XML/DeadlyShadowsFont.xml");

	this->m_nHowToPlay = m_pTM->LoadTexture(L"../resources/graphics/how_to_play_menu.png", D3DCOLOR_XRGB(0, 0, 0));

}

void CTutorialState::Exit(void)
{
	if (this->m_nHowToPlay != -1)
	{
		this->m_pTM->UnloadTexture(this->m_nHowToPlay);
		this->m_nHowToPlay = -1;
	}
}

bool CTutorialState::Input(void)
{
	if (m_pDI->KeyPressed(DIK_ESCAPE))
	{
		CGame::GetInstance()->AddState(CMainMenuState::GetInstance());
		CGame::GetInstance()->RemoveState(this);
	}
	return true;
}

void CTutorialState::Update(float fElapsedTime) { }

void CTutorialState::Render(void)
{

	this->m_pTM->Draw(m_nHowToPlay, 0, 0, 0.8f, 0.6f, nullptr, 0, 0, 0);
	this->m_pD3D->GetSprite()->Flush();


}